package com.xjscrm.common.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 运算规则枚举
 * @Auther: liuqi
 * @Date: 2021/8/14 16:45
 * @Description:
 */
public enum OptEnum {
    EQ("eq","等于"),       //默认
    NQ("nq","不等于"),       //默认
    GT("gt","大于"),
    GE("ge","大于等于"),
    LT("lt","小于"),
    LE("le","小于等于"),
    CT("ct","包含"),
    NCT("nct","不包含"),

    ;
    private String value;
    private String desc;

    OptEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static OptEnum getByValue(String value) {
        if (StringUtils.isBlank(value)) {
            return EQ;
        }
        for (OptEnum type: OptEnum.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        return EQ;
    }
}
